home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / LEMACS.13 (.txt) < prev    next >
GNU Info File  |  1994-09-21  |  51KB  |  902 lines

  1. This is Info file ../info/lemacs, produced by Makeinfo-1.55 from the
  2. input file lemacs.txi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  5. 1991, 1992 Lucid, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided also
  11. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  12. General Public License" are included exactly as in the original, and
  13. provided that the entire resulting derived work is distributed under the
  14. terms of a permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that the sections entitled "The GNU Manifesto",
  18. "Distribution" and "GNU General Public License" may be included in a
  19. translation approved by the author instead of in the original English.
  20. File: lemacs,  Node: Keystrokes,  Next: Representing Keystrokes,  Prev: Screen,  Up: Top
  21. Keystrokes as Building Blocks of Key Sequences
  22. ==============================================
  23.    Earlier versions of GNU Emacs used only the ASCII character set,
  24. which defines 128 different character codes.  Some of these codes are
  25. assigned graphic symbols like `a' and `='; the rest are control
  26. characters, such as `Control-a' (also called `C-a').  `C-a' means you
  27. hold down the CTRL key and then press `a'.
  28.    Keybindings in Lucid GNU Emacs are no longer restricted to the set of
  29. keystrokes that can be represented in ASCII.  Emacs can now tell the
  30. difference between, for example, `Control-h', `Control-Shift-h', and
  31. `Backspace'.
  32.    A keystroke is like a piano chord: you get it by simultaneously
  33. striking several keys.  To be more precise, a keystroke consists of a
  34. possibly empty set of modifiers followed by a single "keysym".  The set
  35. of modifiers is small; it consists of `Control', `Meta', `Super',
  36. `Hyper', and `Shift'.
  37.    The rest of the keys on your keyboard, along with the mouse buttons,
  38. make up the set of keysyms.  A keysym is usually what is printed on the
  39. keys on your keyboard.  Here is a table of some of the symbolic names
  40. for keysyms:
  41. `a,b,c...'
  42.      alphabetic keys
  43. `f1,f2...'
  44.      function keys
  45. `button1'
  46.      left mouse button
  47. `button2'
  48.      middle mouse button
  49. `button3'
  50.      right mouse button
  51. `button1up'
  52.      upstroke on the left mouse button
  53. `button2up'
  54.      upstroke on the middle mouse button
  55. `button3up'
  56.      upstroke on the right mouse button
  57. `return'
  58.      Return key
  59.    Use the variable `keyboard-translate-table' only if you are on a
  60. dumb tty, as it cannot handle input that cannot be represented as ASCII.
  61. The value of this variable is a string used as a translate table for
  62. keyboard input or `nil'.  Each character is looked up in this string
  63. and the contents used instead.  If the string is of length `n',
  64. character codes `N' and up are untranslated.  If you are running Emacs
  65. under X, you should do the translations with the `xmodmap' program
  66. instead.
  67. * Menu:
  68. * Representing Keystrokes::  Using lists of modifiers and keysyms to
  69.                              represent keystrokes.
  70. * Key Sequences::            Combine key strokes into key sequences you can
  71.                              bind to commands.
  72. * String Key Sequences::     Available for upward compatibility.
  73. * Meta Key::                 Using ESC to represent Meta
  74. * Super and Hyper Keys::     Adding modifier keys on certain keyboards.
  75. * Character Representation:: How characters appear in Emacs buffers.
  76. * Commands::                 How commands are bound to key sequences.
  77. File: lemacs,  Node: Representing Keystrokes,  Next: Key Sequences,  Prev: Keystrokes,  Up: Top
  78. Representing Keystrokes
  79. -----------------------
  80.    Lucid GNU Emacs represents keystrokes as lists. Each list consists of
  81. an arbitrary combination of modifiers followed by a single keysym at the
  82. end of the list.  If the keysym corresponds to an ASCII character, you
  83. can use its character code.  (A keystroke may also be represented by an
  84. event object, as returned by the `read-key-sequence' function;
  85. non-programmers need not worry about this.)
  86.    The following table gives some examples of how to list
  87. representations for keystrokes.  Each list consists of sets of
  88. modifiers followed by keysyms:
  89. `(control a)'
  90.      Pressing CTRL and `a' simultaneously.
  91. `(control ?a)'
  92.      Another way of writing the keystroke `C-a'.
  93. `(control 65)'
  94.      Yet another way of writing the keystroke `C-a'.
  95. `(break)'
  96.      Pressing the BREAK key.
  97. `(control meta button2up)'
  98.      Release the middle mouse button, while pressing CTRL and META.
  99. Note: As you define keystrokes, you can use the `shift' key only as a
  100. modifier with characters that do not have a second keysym on the same
  101. key, such as `backspace' and `tab'.  It is an error to define a
  102. keystroke using the shift modifier with keysyms such as `a' and `='.
  103. The correct forms are `A' and `+'.
  104. File: lemacs,  Node: Key Sequences,  Next: String Key Sequences,  Prev: Representing Keystrokes,  Up: Keystrokes
  105. Representing Key Sequences
  106. --------------------------
  107.    A "complete key sequence" is a sequence of keystrokes that Emacs
  108. understands as a unit.  Key sequences are significant because you can
  109. bind them to commands.  Note that not all sequences of keystrokes are
  110. possible key sequences.  In particular, the initial keystrokes in a key
  111. sequence must make up a "prefix key sequence".
  112.    Emacs represents a key sequence as a vector of keystrokes.  Thus, the
  113. schematic representation of a complete key sequence is as follows:
  114.        [(modifier .. modifer keysym) ... (modifier .. modifier keysym)]
  115.    Here are some examples of complete key sequences:
  116. `[(control c) (control a)]'
  117.      Typing `C-c' followed by `C-a'
  118. `[(control c) (control 65)]'
  119.      Typing `C-c' followed by `C-a'. (Using the ASCII code for the
  120.      character `a')
  121. `[(control c) (break)]'
  122.      Typing `C-c' followed by the `break' character.
  123.    A "prefix key sequence" is the beginning of a series of longer
  124. sequences that are valid key sequences; adding any single keystroke to
  125. the end of a prefix results in a valid key sequence.  For example,
  126. `control-x' is standardly defined as a prefix.  Thus, there is a
  127. two-character key sequence starting with `C-x' for each valid
  128. keystroke, giving numerous possibilities.  Here are some samples:
  129.    * `[(control x) (c)]'
  130.    * `[(control x) (control c)]'
  131.    Adding one character to a prefix key does not have to form a complete
  132. key.  It could make another, longer prefix.  For example, `[(control x)
  133. (\4)]' is itself a prefix that leads to any number of different
  134. three-character keys, including `[(control x) (\4) (f)]', `[(control x)
  135. (\4) (b)]' and so on.  It would be possible to define one of those
  136. three-character sequences as a prefix, creating a series of
  137. four-character keys, but we did not define any of them this way.
  138.    By contrast, the two-character sequence `[(control f) (control k)]'
  139. is not a key, because the `(control f)' is a complete key sequence in
  140. itself.  It's impossible to give `[(control f (control k)]' an
  141. independent meaning as a command as long as `(control f)' retains its
  142. meaning, because what we have is really two commands.
  143.    The predefined prefix key sequences in Emacs are `(control c)',
  144. `(control x)', `(control h)', `[(control x) (\4)]', and `escape'.  You
  145. can customize Emacs, and could make new prefix keys, or eliminate the
  146. default key sequences.  *Note Key Bindings::.
  147.    Whether a particular key sequence is valid can be changed by
  148. customization.  For example, if you redefine `(control f)' as a prefix,
  149. `[(control f) (control k)]' automatically becomes a valid key sequence
  150. (complete, unless you define it as a prefix as well).  Conversely, if
  151. you remove the prefix definition of `[(control x) (\4)]', `[(control x)
  152. (\4) (f)]' (or `[(control x) (\4) ANYTHING]') is no longer a valid key
  153. sequence.
  154.    Note that the above paragraphs uses \4 instead of simply 4, because
  155. \4 is the symbol whose name is "4", and plain 4 is the integer 4, which
  156. would have been interpreted as the ASCII value.  Another way of
  157. representing the symbol whose name is "4" is to write ?4, which would be
  158. interpreted as the number 52, which is the ASCII code for the character
  159. "4".  We could therefore actually have written 52 directly but that is
  160. far less clear.
  161. File: lemacs,  Node: String Key Sequences,  Next: Meta Key,  Prev: Key Sequences,  Up: Keystrokes
  162. String Key Sequences
  163. --------------------
  164.    For backward compatibility, you may also represent a key sequence
  165. using strings.  For example, we have the following equivalent
  166. representations:
  167. `"\C-c\C-c"'
  168.      `[(control c) (control c)]'
  169. `"\e\C-c"'
  170.      `[(meta control c)]'
  171. * Menu:
  172. * Meta Key:: Assignment of the META Key
  173. * Super and Hyper Keys:: Assignment of the SUPER and HYPER Keys
  174. File: lemacs,  Node: Meta Key,  Next: Super and Hyper Keys,  Prev: String Key Sequences,  Up: Keystrokes
  175. Assignment of the META Key
  176. --------------------------
  177.    Not all terminals have the complete set of modifiers.  Terminals
  178. that have a Meta key allow you to type Meta characters by just holding
  179. that key down.  To type `Meta-a', hold down META and press `a'.  On
  180. those terminals, the META key works like the SHIFT key.  Such a key is
  181. not always labeled META, however, as this function is often a special
  182. option for a key with some other primary purpose.
  183.    If there is no META key, you can still type Meta characters using
  184. two-character sequences starting with ESC.  To enter `M-a', you could
  185. type `ESC a'.  To enter `C-M-a', you would type `ESC C-a'.  ESC is
  186. allowed on terminals with Meta keys, too, in case you have formed a
  187. habit of using it.
  188.    If you are running under X and do not have a Meta key, it is
  189. possible to reconfigure some other key to be a Meta key.  *Note Super
  190. and Hyper Keys::.
  191.    Emacs believes the terminal has a META key if the variable
  192. `meta-flag' is non-`nil'.  Normally this is set automatically according
  193. to the termcap entry for your terminal type.  However, sometimes the
  194. termcap entry is wrong, and then it is useful to set this variable
  195. yourself.  *Note Variables::, for how to do this.
  196.    Note: If you are running under the X window system, the setting of
  197. the `meta-flag' variable is irrelevant.
  198. File: lemacs,  Node: Super and Hyper Keys,  Next: Character Representation,  Prev: Meta Key,  Up: Keystrokes
  199. Assignment of the SUPER and HYPER Keys
  200. --------------------------------------
  201.    Most keyboards do not, by default, have SUPER or HYPER modifier
  202. keys.  Under X, you can simulate the SUPER or HYPER key if you want to
  203. bind keys to sequences using `super' and `hyper'.  You can use the
  204. `xmodmap' program to do this.
  205.    For example, to turn your CAPS-LOCK key into a SUPER key, do the
  206. following:
  207.    Create a file called `~/.xmodmap'.  In this file, place the lines
  208.          remove Lock = Caps_Lock
  209.          keysym Caps_Lock = Super_L
  210.          add Mod2 = Super_L
  211.    The first line says that the key that is currently called `Caps_Lock'
  212. should no longer behave as a "lock" key.  The second line says that
  213. this should now be called `Super_L' instead.  The third line says that
  214. the key called `Super_L' should be a modifier key, which produces the
  215. `Mod2' modifier.
  216.    To create a Meta or Hyper key instead of a Super key, replace the
  217. word "Super" above with Meta or Hyper.
  218.    Just after you start up X, execute the command `xmodmap /.xmodmap'.
  219. You can add this command to the appropriate initialization file to have
  220. the command executed automatically.
  221.    If you have problems, see the documentation for the `xmodmap'
  222. program.  The X keyboard model is quite complicated, and explaining it
  223. is beyond the scope of this manual.
  224. File: lemacs,  Node: Key Bindings,  Next: Syntax,  Prev: Keyboard Macros,  Up: Customization
  225. Customizing Key Bindings
  226. ========================
  227.    This section deals with the "keymaps" which define the bindings
  228. between keys and functions, and shows how you can customize these
  229. bindings.
  230.    A command is a Lisp function whose definition provides for
  231. interactive use.  Like every Lisp function, a command has a function
  232. name, a Lisp symbol whose name usually consists of lower case letters
  233. and hyphens.
  234. * Menu:
  235. * Keymaps::    Definition of the keymap data structure.
  236.                Names of Emacs's standard keymaps.
  237. * Rebinding::  How to redefine one key's meaning conveniently.
  238. * Disabling::  Disabling a command means confirmation is required
  239.                 before it can be executed.  This is done to protect
  240.                 beginners from surprises.
  241. File: lemacs,  Node: Keymaps,  Next: Disabling,  Up: Key Bindings
  242. Keymaps
  243. -------
  244.    The bindings between characters and command functions are recorded in
  245. data structures called "keymaps".  Emacs has many of these.  One, the
  246. "global" keymap, defines the meanings of the single-character keys that
  247. are defined regardless of major mode.  It is the value of the variable
  248. `global-map'.
  249.    Each major mode has another keymap, its "local keymap", which
  250. contains overriding definitions for the single-character keys that are
  251. redefined in that mode.  Each buffer records which local keymap is
  252. installed for it at any time, and the current buffer's local keymap is
  253. the only one that directly affects command execution.  The local keymaps
  254. for Lisp mode, C mode, and many other major modes always exist even when
  255. not in use.  They are the values of the variables `lisp-mode-map',
  256. `c-mode-map', and so on.  For less frequently used major modes, the
  257. local keymap is sometimes constructed only when the mode is used for the
  258. first time in a session, to save space.
  259.    There are local keymaps for the minibuffer too; they contain various
  260. completion and exit commands.
  261.    * `minibuffer-local-map' is used for ordinary input (no completion).
  262.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  263.      like RET.  This is used mainly for Mocklisp compatibility.
  264.    * `minibuffer-local-completion-map' is for permissive completion.
  265.    * `minibuffer-local-must-match-map' is for strict completion and for
  266.      cautious completion.
  267.    * `repeat-complex-command-map' is for use in `C-x ESC'.
  268.    * `isearch-mode-map' contains the bindings of the special keys which
  269.      are bound in the pseudo-mode entered with `C-s' and `C-r'.
  270.    Finally, each prefix key has a keymap which defines the key sequences
  271. that start with it.  For example, `ctl-x-map' is the keymap used for
  272. characters following a `C-x'.
  273.    * `ctl-x-map' is the variable name for the map used for characters
  274.      that follow `C-x'.
  275.    * `help-map' is used for characters that follow `C-h'.
  276.    * `esc-map' is for characters that follow ESC. All Meta characters
  277.      are actually defined by this map.
  278.    * `ctl-x-4-map' is for characters that follow `C-x 4'.
  279.    * `mode-specific-map' is for characters that follow `C-c'.
  280.    The definition of a prefix key is the keymap to use for looking up
  281. the following character.  Sometimes, the definition is actually a Lisp
  282. symbol whose function definition is the following character keymap.  The
  283. effect is the same, but it provides a command name for the prefix key
  284. that you can use as a description of what the prefix key is for.  Thus,
  285. the binding of `C-x' is the symbol `Ctl-X-Prefix', whose function
  286. definition is the keymap for `C-x' commands, the value of `ctl-x-map'.
  287.    Prefix key definitions can appear in either the global map or a
  288. local map.  The definitions of `C-c', `C-x', `C-h' and ESC as prefix
  289. keys appear in the global map, so these prefix keys are always
  290. available.  Major modes can locally redefine a key as a prefix by
  291. putting a prefix key definition for it in the local map.
  292.    A mode can also put a prefix definition of a global prefix character
  293. such as `C-x' into its local map.  This is how major modes override the
  294. definitions of certain keys that start with `C-x'.  This case is
  295. special, because the local definition does not entirely replace the
  296. global one.  When both the global and local definitions of a key are
  297. other keymaps, the next character is looked up in both keymaps, with
  298. the local definition overriding the global one.  So, the character
  299. after the `C-x' is looked up in both the major mode's own keymap for
  300. redefined `C-x' commands and in `ctl-x-map'.  If the major mode's own
  301. keymap for `C-x' commands contains `nil', the definition from the global
  302. keymap for `C-x' commands is used.
  303. * Menu:
  304. * Rebinding::                 Changing Key Bindings Interactively
  305. * Programmatic Rebinding::    Changing Key Bindings Programmatically
  306. * Key Bindings Using Strings::Using Strings for Changings Key Bindings
  307. File: lemacs,  Node: Rebinding,  Next: Programmatic Rebinding,  Prev: Keymaps,  Up: Keymaps
  308. Changing Key Bindings Interactively
  309. -----------------------------------
  310.    You can redefine an Emacs key by changing its entry in a keymap.
  311. You can change the global keymap, in which case the change is effective
  312. in all major modes except those that have their own overriding local
  313. definitions for the same key.  Or you can change the current buffer's
  314. local map, which affects all buffers using the same major mode.
  315. `M-x global-set-key RET KEY CMD RET'
  316.      Defines KEY globally to run CMD.
  317. `M-x local-set-key RET KEYS CMD RET'
  318.      Defines KEY locally (in the major mode now in effect) to run CMD.
  319. `M-x local-unset-key RET KEYS RET'
  320.      Removes the local binding of KEY.
  321.    CMD is a symbol naming an interactively-callable function.
  322.    When called interactively, KEY is the next complete key sequence
  323. that you type.  When called as a function, KEY is a string, a vector of
  324. events or a vector of key-description lists as described in the the
  325. `define-key' function description.  The binding goes in the current
  326. buffer's local map, which is shared with other buffers in the same
  327. major mode.
  328.    The following example,
  329.      M-x global-set-key RET C-f next-line RET
  330. redefines `C-f' to move down a line.  The fact that CMD is read second
  331. makes it serve as a kind of confirmation for KEY.
  332.    These functions offer no way to specify a particular prefix keymap as
  333. the one to redefine in, but that is not necessary, as you can include
  334. prefixes in KEY.  KEY is read by reading characters one by one until
  335. they amount to a complete key (that is, not a prefix key).  Thus, if
  336. you type `C-f' for KEY, Emacs enters the minibuffer immediately to read
  337. CMD.  But if you type `C-x', another character is read; if that
  338. character is `4', another character is read, and so on.  For example,
  339.      M-x global-set-key RET C-x 4 $ spell-other-window RET
  340. redefines `C-x 4 $' to run the (fictitious) command
  341. `spell-other-window'.
  342.    The most general way to modify a keymap is the function
  343. `define-key', used in Lisp code (such as your `.emacs' file).
  344. `define-key' takes three arguments: the keymap, the key to modify in
  345. it, and the new definition.  *Note Init File::, for an example.
  346. `substitute-key-definition' is used similarly; it takes three
  347. arguments, an old definition, a new definition and a keymap, and
  348. redefines in that keymap all keys that were previously defined with the
  349. old definition to have the new definition instead.
  350. File: lemacs,  Node: Programmatic Rebinding,  Next: Key Bindings Using Strings,  Prev: Rebinding,  Up: Keymaps
  351. Changing Key Bindings Programmatically
  352. --------------------------------------
  353.    You can use the functions `global-set-key' and `define-key' to
  354. rebind keys under program control.
  355. ``(global-set-key KEYS CMD)''
  356.      Defines KEYS globally to run CMD.
  357. ``(define-key KEYMAP KEYS DEF)''
  358.      Defines KEYS to run CMD in the keymap KEYMAP.
  359.    KEYMAP is a keymap object.
  360.    KEYS is the sequence of keystrokes to bind.
  361.    DEF is anything that can be a key's definition:
  362.    * `nil' meaning key is undefined in this keymap.
  363.    * A command, that is, a Lisp function suitable for interactive
  364.      calling.
  365.    * A string or key sequence vector, which is treated as a keyboard
  366.      macro.
  367.    * A keymap to define a prefix key.
  368.    * A symbol so that when the key is looked up, the symbol stands for
  369.      its function definition, which should at that time be one of the
  370.      above, or another symbol whose function definition is used, and so
  371.      on.
  372.    * A cons, `(string . defn)', meaning that DEFN is the definition
  373.      (DEFN should be a valid definition in its own right).
  374.    * A cons, `(keymap . char)', meaning use the definition of CHAR in
  375.      map KEYMAP.
  376.    For backward compatibility, Lucid GNU Emacs allows you to specify key
  377. sequences as strings.  However, the preferred method is to use the
  378. representations of key sequences as vectors of keystrokes.  *Note
  379. Keystrokes::, for more information about the rules for constructing key
  380. sequences.
  381.    Emacs allows you to abbreviate representations for key sequences in
  382. most places where there is no ambiguity.  Here are some rules for
  383. abbreviation:
  384.    * The keysym by itself is equivalent to a list of just that keysym,
  385.      i.e.  `f1' is equivalent to `(f1)'.
  386.    * A keystroke by itself is equivalent to a vector containing just
  387.      that keystroke, i.e.  `(control a)' is equivalent to `[(control
  388.      a)]'
  389.    * You can use ASCII codes for keysyms that have them. i.e.  `65' is
  390.      equivalent to `A'. (This is not so much an abbreviation as an
  391.      alternate representation.)
  392.    Here are some examples of programmatically binding keys:
  393.      ;;;  Bind `my-command' to f1
  394.      
  395.      (global-set-key 'f1 'my-command)
  396.      
  397.      ;;;  Bind `my-command' to `Shift-f1'
  398.      (global-set-key '(shift f1) 'my-command)
  399.      
  400.      ;;; Bind `my-command' to `C-c Shift-f1'
  401.      (global-set-key '[(control c) (shift f1)] 'my-command)
  402.      
  403.      ;;; Bind `my-command' to the middle mouse button.
  404.      (global-set-key 'button2 'my-command)
  405.      
  406.      ;;; Bind `my-command' to `META CTL Right Mouse Button'
  407.      ;;; in the keymap that is in force when you are running `dired'.
  408.      (define-key dired-mode-map '(meta control button3) 'my-command)
  409. File: lemacs,  Node: Key Bindings Using Strings,  Prev: Programmatic Rebinding,  Up: Keymaps
  410.    For backward compatibility, you can still use strings to represent
  411. key sequences.  Thus you can use comands like the following:
  412.      ;;; Bind `end-of-line' to `C-f'
  413.      (global-set-key "\C-f" 'end-of-line)
  414.    Note, however, that in some cases you may be binding more than one
  415. key sequence by using a single command.  This situation can arise
  416. because in ASCII, `C-i' and TAB have the same representation.
  417. Therefore, when Emacs sees:
  418.      (global-set-key "\C-i" 'end-of-line)
  419.    it is unclear whether the user intended to bind `C-i' or TAB.  The
  420. solution Lucid GNU Emacs adopts is to bind both of these key sequences.
  421.    After binding a command to two key sequences with a form like
  422.          (define-key global-map "\^X\^I" 'command-1)
  423.    it is possible to redefine only one of those sequences like so:
  424.          (define-key global-map [(control x) (control i)] 'command-2)
  425.          (define-key global-map [(control x) tab] 'command-3)
  426.    This applies only when running under a window system.  If you are
  427. talking to Emacs through an ASCII-only channel, you do not get any of
  428. these features.
  429.    Here is a table of pairs of key sequences that behave in a similar
  430. fashion:
  431.              control h      backspace
  432.              control l      clear
  433.              control i      tab
  434.              control m      return
  435.              control j      linefeed
  436.              control [      escape
  437.              control @      control space
  438. File: lemacs,  Node: Disabling,  Prev: Keymaps,  Up: Key Bindings
  439. Disabling Commands
  440. ------------------
  441.    Disabling a command marks it as requiring confirmation before it can
  442. be executed.  The purpose of disabling a command is to prevent
  443. beginning users from executing it by accident and being confused.
  444.    The direct mechanism for disabling a command is to have a non-`nil'
  445. `disabled' property on the Lisp symbol for the command.  These
  446. properties are normally set by the user's `.emacs' file with Lisp
  447. expressions such as
  448.      (put 'delete-region 'disabled t)
  449.    If the value of the `disabled' property is a string, that string is
  450. included in the message printed when the command is used:
  451.      (put 'delete-region 'disabled
  452.           "Text deleted this way cannot be yanked back!\n")
  453.    You can disable a command either by editing the `.emacs' file
  454. directly or with the command `M-x disable-command', which edits the
  455. `.emacs' file for you.  *Note Init File::.
  456.    When you attempt to invoke a disabled command interactively in Emacs,
  457. a window is displayed containing the command's name, its documentation,
  458. and some instructions on what to do next; then Emacs asks for input
  459. saying whether to execute the command as requested, enable it and
  460. execute, or cancel it.  If you decide to enable the command, you are
  461. asked whether to do this permanently or just for the current session.
  462. Enabling permanently works by automatically editing your `.emacs' file.
  463. You can use `M-x enable-command' at any time to enable any command
  464. permanently.
  465.    Whether a command is disabled is independent of what key is used to
  466. invoke it; it also applies if the command is invoked using `M-x'.
  467. Disabling a command has no effect on calling it as a function from Lisp
  468. programs.
  469. File: lemacs,  Node: Syntax,  Next: Init File,  Prev: Key Bindings,  Up: Customization
  470. The Syntax Table
  471. ================
  472.    All the Emacs commands which parse words or balance parentheses are
  473. controlled by the "syntax table".  The syntax table specifies which
  474. characters are opening delimiters, which are parts of words, which are
  475. string quotes, and so on.  Actually, each major mode has its own syntax
  476. table (though sometimes related major modes use the same one) which it
  477. installs in each buffer that uses that major mode.  The syntax table
  478. installed in the current buffer is the one that all commands use, so we
  479. call it "the" syntax table.  A syntax table is a Lisp object, a vector
  480. of length 256 whose elements are numbers.
  481. * Menu:
  482. * Entry: Syntax Entry.    What the syntax table records for each character.
  483. * Change: Syntax Change.  How to change the information.
  484. File: lemacs,  Node: Syntax Entry,  Next: Syntax Change,  Prev: Syntax,  Up: Syntax
  485. Information about Each Character
  486. --------------------------------
  487.    The syntax table entry for a character is a number that encodes six
  488. pieces of information:
  489.    * The syntactic class of the character, represented as a small
  490.      integer.
  491.    * The matching delimiter, for delimiter characters only.  The
  492.      matching delimiter of `(' is `)', and vice versa.
  493.    * A flag saying whether the character is the first character of a
  494.      two-character comment starting sequence.
  495.    * A flag saying whether the character is the second character of a
  496.      two-character comment starting sequence.
  497.    * A flag saying whether the character is the first character of a
  498.      two-character comment ending sequence.
  499.    * A flag saying whether the character is the second character of a
  500.      two-character comment ending sequence.
  501.    The syntactic classes are stored internally as small integers, but
  502. are usually described to or by the user with characters.  For example,
  503. `(' is used to specify the syntactic class of opening delimiters.  Here
  504. is a table of syntactic classes, with the characters that specify them.
  505.      The class of whitespace characters.
  506.      The class of word-constituent characters.
  507.      The class of characters that are part of symbol names but not
  508.      words.  This class is represented by `_' because the character `_'
  509.      has this class in both C and Lisp.
  510.      The class of punctuation characters that do not fit into any other
  511.      special class.
  512.      The class of opening delimiters.
  513.      The class of closing delimiters.
  514.      The class of expression-adhering characters.  These characters are
  515.      part of a symbol if found within or adjacent to one, and are part
  516.      of a following expression if immediately preceding one, but are
  517.      like whitespace if surrounded by whitespace.
  518.      The class of string-quote characters.  They match each other in
  519.      pairs, and the characters within the pair all lose their syntactic
  520.      significance except for the `\' and `/' classes of escape
  521.      characters, which can be used to include a string-quote inside the
  522.      string.
  523.      The class of self-matching delimiters.  This is intended for TeX's
  524.      `$', which is used both to enter and leave math mode.  Thus, a
  525.      pair of matching `$' characters surround each piece of math mode
  526.      TeX input.  A pair of adjacent `$' characters act like a single
  527.      one for purposes of matching
  528.      The class of escape characters that always just deny the following
  529.      character its special syntactic significance.  The character after
  530.      one of these escapes is always treated as alphabetic.
  531.      The class of C-style escape characters.  In practice, these are
  532.      treated just like `/'-class characters, because the extra
  533.      possibilities for C escapes (such as being followed by digits)
  534.      have no effect on where the containing expression ends.
  535.      The class of comment-starting characters.  Only single-character
  536.      comment starters (such as `;' in Lisp mode) are represented this
  537.      way.
  538.      The class of comment-ending characters.  Newline has this syntax in
  539.      Lisp mode.
  540.    The characters flagged as part of two-character comment delimiters
  541. can have other syntactic functions most of the time.  For example, `/'
  542. and `*' in C code, when found separately, have nothing to do with
  543. comments.  The comment-delimiter significance overrides when the pair of
  544. characters occur together in the proper order.  Only the list and sexp
  545. commands use the syntax table to find comments; the commands
  546. specifically for comments have other variables that tell them where to
  547. find comments.  And the list and sexp commands notice comments only if
  548. `parse-sexp-ignore-comments' is non-`nil'.  This variable is set to
  549. `nil' in modes where comment-terminator sequences are liable to appear
  550. where there is no comment; for example, in Lisp mode where the comment
  551. terminator is a newline but not every newline ends a comment.
  552. File: lemacs,  Node: Syntax Change,  Prev: Syntax Entry,  Up: Syntax
  553. Altering Syntax Information
  554. ---------------------------
  555.    It is possible to alter a character's syntax table entry by storing
  556. a new number in the appropriate element of the syntax table, but it
  557. would be hard to determine what number to use.  Emacs therefore
  558. provides a command that allows you to specify the syntactic properties
  559. of a character in a convenient way.
  560.    `M-x modify-syntax-entry' is the command to change a character's
  561. syntax.  It can be used interactively, and is also used by major modes
  562. to initialize their own syntax tables.  Its first argument is the
  563. character to change.  The second argument is a string that specifies the
  564. new syntax.  When called from Lisp code, there is a third, optional
  565. argument, which specifies the syntax table in which to make the change.
  566. If not supplied, or if this command is called interactively, the third
  567. argument defaults to the current buffer's syntax table.
  568.   1. The first character in the string specifies the syntactic class.
  569.      It is one of the characters in the previous table (*note Syntax
  570.      Entry::.).
  571.   2. The second character is the matching delimiter.  For a character
  572.      that is not an opening or closing delimiter, this should be a
  573.      space, and may be omitted if no following characters are needed.
  574.   3. The remaining characters are flags.  The flag characters allowed
  575.      are
  576.     `1'
  577.           Flag this character as the first of a two-character comment
  578.           starting sequence.
  579.     `2'
  580.           Flag this character as the second of a two-character comment
  581.           starting sequence.
  582.     `3'
  583.           Flag this character as the first of a two-character comment
  584.           ending sequence.
  585.     `4'
  586.           Flag this character as the second of a two-character comment
  587.           ending sequence.
  588.    Use `C-h s' (`describe-syntax') to display a description of the
  589. contents of the current syntax table.  The description of each
  590. character includes both the string you have to pass to
  591. `modify-syntax-entry' to set up that character's current syntax, and
  592. some English to explain that string if necessary.
  593. File: lemacs,  Node: Init File,  Next: Audible Bell,  Prev: Syntax,  Up: Customization
  594. The Init File, .emacs
  595. =====================
  596.    When you start Emacs, it normally loads the file `.emacs' in your
  597. home directory.  This file, if it exists, should contain Lisp code.  It
  598. is called your initialization file or "init file".  Use the command
  599. line switches `-q' and `-u' to tell Emacs whether to load an init file
  600. (*note Entering Emacs::.).
  601.    When the `.emacs' file is read, the variable `init-file-user' says
  602. which users init file it is.  The value may be the null string or a
  603. string containing a user's name.  If the value is a null string, it
  604. means that the init file was taken from the user that originally logged
  605.    In all cases, `(concat "~" init-file-user "/")' evaluates to the
  606. directory name of the directory where the `.emacs' file was looked for.
  607.    At some sites, there is a "default init file", which is the library
  608. named `default.el', found via the standard search path for libraries.
  609. The Emacs distribution contains no such library; your site may create
  610. one for local customizations.  If this library exists, it is loaded
  611. whenever you start Emacs.  But your init file, if any, is loaded first;
  612. if it sets `inhibit-default-init' non-`nil', then `default' is not
  613. loaded.
  614.    If you have a large amount of code in your `.emacs' file, you should
  615. move it into another file named `SOMETHING.el', byte-compile it (*note
  616. Lisp Libraries::.), and load that file from your `.emacs' file using
  617. `load'.
  618. * Menu:
  619. * Init Syntax::     Syntax of constants in Emacs Lisp.
  620. * Init Examples::   How to do some things with an init file.
  621. * Terminal Init::   Each terminal type can have an init file.
  622. File: lemacs,  Node: Init Syntax,  Next: Init Examples,  Prev: Init File,  Up: Init File
  623. Init File Syntax
  624. ----------------
  625.    The `.emacs' file contains one or more Lisp function call
  626. expressions.  Each consists of a function name followed by arguments,
  627. all surrounded by parentheses.  For example, `(setq fill-column 60)'
  628. represents a call to the function `setq' which is used to set the
  629. variable `fill-column' (*note Filling::.) to 60.
  630.    The second argument to `setq' is an expression for the new value of
  631. the variable.  This can be a constant, a variable, or a function call
  632. expression.  In `.emacs', constants are used most of the time.  They
  633. can be:
  634. Numbers:
  635.      Integers are written in decimal, with an optional initial minus
  636.      sign.
  637.      If a sequence of digits is followed by a period and another
  638.      sequence of digits, it is interpreted as a floating point number.
  639. Strings:
  640.      Lisp string syntax is the same as C string syntax with a few extra
  641.      features.  Use a double-quote character to begin and end a string
  642.      constant.
  643.      Newlines and special characters may be present literally in
  644.      strings.  They can also be represented as backslash sequences:
  645.      `\n' for newline, `\b' for backspace, `\r' for return, `\t' for
  646.      tab, `\f' for formfeed (control-l), `\e' for escape, `\\' for a
  647.      backslash, `\"' for a double-quote, or `\OOO' for the character
  648.      whose octal code is OOO.  Backslash and double-quote are the only
  649.      characters for which backslash sequences are mandatory.
  650.      You can use `\C-' as a prefix for a control character, as in
  651.      `\C-s' for ASCII Control-S, and `\M-' as a prefix for a meta
  652.      character, as in `\M-a' for Meta-A or `\M-\C-a' for Control-Meta-A.
  653. Characters:
  654.      Lisp character constant syntax consists of a `?' followed by
  655.      either a character or an escape sequence starting with `\'.
  656.      Examples: `?x', `?\n', `?\"', `?\)'.  Note that strings and
  657.      characters are not interchangeable in Lisp; some contexts require
  658.      one and some contexts require the other.
  659. True:
  660.      `t' stands for `true'.
  661. False:
  662.      `nil' stands for `false'.
  663. Other Lisp objects:
  664.      Write a single-quote (') followed by the Lisp object you want.
  665. File: lemacs,  Node: Init Examples,  Next: Terminal Init,  Prev: Init Syntax,  Up: Init File
  666. Init File Examples
  667. ------------------
  668.    Here are some examples of doing certain commonly desired things with
  669. Lisp expressions:
  670.    * Make TAB in C mode just insert a tab if point is in the middle of a
  671.      line.
  672.           (setq c-tab-always-indent nil)
  673.      Here we have a variable whose value is normally `t' for `true' and
  674.      the alternative is `nil' for `false'.
  675.    * Make searches case sensitive by default (in all buffers that do not
  676.      override this).
  677.           (setq-default case-fold-search nil)
  678.      This sets the default value, which is effective in all buffers
  679.      that do not have local values for the variable.  Setting
  680.      `case-fold-search' with `setq' affects only the current buffer's
  681.      local value, which is probably not what you want to do in an init
  682.      file.
  683.    * Make Text mode the default mode for new buffers.
  684.           (setq default-major-mode 'text-mode)
  685.      Note that `text-mode' is used because it is the command for
  686.      entering the mode we want.  A single-quote is written before it to
  687.      make a symbol constant; otherwise, `text-mode' would be treated as
  688.      a variable name.
  689.    * Turn on Auto Fill mode automatically in Text mode and related
  690.      modes.
  691.           (setq text-mode-hook
  692.             '(lambda () (auto-fill-mode 1)))
  693.      Here we have a variable whose value should be a Lisp function.  The
  694.      function we supply is a list starting with `lambda', and a single
  695.      quote is written in front of it to make it (for the purpose of this
  696.      `setq') a list constant rather than an expression.  Lisp functions
  697.      are not explained here; for mode hooks it is enough to know that
  698.      `(auto-fill-mode 1)' is an expression that will be executed when
  699.      Text mode is entered.  You could replace it with any other
  700.      expression that you like, or with several expressions in a row.
  701.           (setq text-mode-hook 'turn-on-auto-fill)
  702.      This is another way to accomplish the same result.
  703.      `turn-on-auto-fill' is a symbol whose function definition is
  704.      `(lambda () (auto-fill-mode 1))'.
  705.    * Load the installed Lisp library named `foo' (actually a file
  706.      `foo.elc' or `foo.el' in a standard Emacs directory).
  707.           (load "foo")
  708.      When the argument to `load' is a relative pathname, not starting
  709.      with `/' or `~', `load' searches the directories in `load-path'
  710.      (*note Loading::.).
  711.    * Load the compiled Lisp file `foo.elc' from your home directory.
  712.           (load "~/foo.elc")
  713.      Here an absolute file name is used, so no searching is done.
  714.    * Rebind the key `C-x l' to run the function `make-symbolic-link'.
  715.           (global-set-key "\C-xl" 'make-symbolic-link)
  716.      or
  717.           (define-key global-map "\C-xl" 'make-symbolic-link)
  718.      Note once again the single-quote used to refer to the symbol
  719.      `make-symbolic-link' instead of its value as a variable.
  720.    * Do the same thing for C mode only.
  721.           (define-key c-mode-map "\C-xl" 'make-symbolic-link)
  722.    * Bind the function key F1 to a command in C mode.  Note that the
  723.      names of function keys must be lower case.
  724.           (define-key c-mode-map 'f1 'make-symbolic-link)
  725.    * Bind the shifted version of F1 to a command.
  726.           (define-key c-mode-map '(shift f1) 'make-symbolic-link)
  727.    * Redefine all keys which now run `next-line' in Fundamental mode to
  728.      run `forward-line' instead.
  729.           (substitute-key-definition 'next-line 'forward-line
  730.                                      global-map)
  731.    * Make `C-x C-v' undefined.
  732.           (global-unset-key "\C-x\C-v")
  733.      One reason to undefine a key is so that you can make it a prefix.
  734.      Simply defining `C-x C-v ANYTHING' would make `C-x C-v' a prefix,
  735.      but `C-x C-v' must be freed of any non-prefix definition first.
  736.    * Make `$' have the syntax of punctuation in Text mode.  Note the
  737.      use of a character constant for `$'.
  738.           (modify-syntax-entry ?\$ "." text-mode-syntax-table)
  739.    * Enable the use of the command `eval-expression' without
  740.      confirmation.
  741.           (put 'eval-expression 'disabled nil)
  742. File: lemacs,  Node: Terminal Init,  Prev: Init Examples,  Up: Init File
  743. Terminal-specific Initialization
  744. --------------------------------
  745.    Each terminal type can have a Lisp library to be loaded into Emacs
  746. when it is run on that type of terminal.  For a terminal type named
  747. TERMTYPE, the library is called `term/TERMTYPE' and it is found by
  748. searching the directories `load-path' as usual and trying the suffixes
  749. `.elc' and `.el'.  Normally it appears in the subdirectory `term' of
  750. the directory where most Emacs libraries are kept.
  751.    The usual purpose of the terminal-specific library is to define the
  752. escape sequences used by the terminal's function keys using the library
  753. `keypad.el'.  See the file `term/vt100.el' for an example of how this
  754. is done.
  755.    When the terminal type contains a hyphen, only the part of the name
  756. before the first hyphen is significant in choosing the library name.
  757. Thus, terminal types `aaa-48' and `aaa-30-rv' both use the library
  758. `term/aaa'.  The code in the library can use `(getenv "TERM")' to find
  759. the full terminal type name.
  760.    The library's name is constructed by concatenating the value of the
  761. variable `term-file-prefix' and the terminal type.  Your `.emacs' file
  762. can prevent the loading of the terminal-specific library by setting
  763. `term-file-prefix' to `nil'.
  764.    The value of the variable `term-setup-hook', if not `nil', is called
  765. as a function of no arguments at the end of Emacs initialization, after
  766. both your `.emacs' file and any terminal-specific library have been
  767. read.  You can set the value in the `.emacs' file to override part of
  768. any of the terminal-specific libraries and to define initializations
  769. for terminals that do not have a library.
  770. File: lemacs,  Node: Audible Bell,  Next: Faces,  Prev: Init File,  Up: Customization
  771. Changing the Bell Sound
  772. =======================
  773.    You can now change how the audible bell sounds using the variable
  774. `sound-alist'.
  775.    `sound-alist''s value is an alist associating symbols with strings
  776. of audio-data.  When `ding' is called with one of the symbols, the
  777. associated sound data is played instead of the standard beep.  This
  778. only works if you are logged in on the console of a SPARCstation. To
  779. listen to a sound of the provided type, call the function `play-sound'
  780. with the argument SOUND. You can also set the volume of the sound with
  781. the optional arugment VOLUME.
  782.    Elements of the list should be of one of the following forms:
  783.         ( symbol . string-or-symbol )
  784.         ( symbol integer string-or-symbol )
  785.    If `string-or-symbol' is a string, it should contain raw sound data,
  786. the contents of a `.au' file.  If it is a symbol, the symbol is
  787. considered an alias for some other element, and the sound-player looks
  788. for that next.  If the integer is provided, it is the volume at which
  789. the sound should be played, from 0 to 100.
  790.    If an element of this alist begins with the symbol `default', that
  791. sound is used when no other sound is appropriate.
  792.    If the symbol `t' is in place of a sound-string, Emacs uses the
  793. default X beep.  This allows you to define beep-types of different
  794. volumes even when not running on the console of a SPARCstation.
  795.    You can add things to this list by calling the function
  796. `load-sound-file', which reads in an audio-file and adds its data to
  797. the sound-alist. You can specify the sound with the SOUND-NAME argument
  798. and the file into which the sounds are loaded with the FILENAME
  799. argument. The optional VOLUME argument sets the volume.
  800.    `load-sound-file (filename sound-name &optional volume)'
  801.    To load and install some sound files as beep-types, use the function
  802. `load-default-sounds' (note that this only works if you are on display
  803. 0 of a SPARCstation).
  804.    The following beep-types are used by Emacs itself. Other Lisp
  805. packages may use other beep types, but these are the ones that the C
  806. kernel of Emacs uses.
  807. `auto-save-error'
  808.      An auto-save does not succeed
  809. `command-error'
  810.      The Emacs command loop catches an error
  811. `undefined-key'
  812.      You type a key that is undefined
  813. `undefined-click'
  814.      You use an undefined mouse-click combination
  815. `no-completion'
  816.      Completion was not possible
  817. `y-or-n-p'
  818.      You type something other than the required `y' or `n'
  819. `yes-or-no-p'
  820.      When you type something other than `yes' or `no'
  821. File: lemacs,  Node: Faces,  Prev: Audible Bell,  Up: Customization
  822. Faces
  823. =====
  824.    Lucid GNU Emacs has objects called extents and faces.  An "extent"
  825. is a region of text and a "face" is a collection of textual attributes,
  826. such as fonts and colors.  Every extent is displayed in some face,
  827. therefore, changing the properties of a face immediately updates the
  828. display of all associated extents.  Faces can be screen-local: you can
  829. have a region of text that displays with completely different
  830. attributes when its buffer is viewed from a different X window.
  831.    The display attributes of faces may be specified either in Lisp or
  832. through the X resource manager.
  833. Customizing Faces
  834. -----------------
  835.    You can change the face of an extent with the functions in this
  836. section.  All the functions prompt for a FACE as an argument; use
  837. completion for a list of possible values.
  838. `M-x invert-face'
  839.      Swap the foreground and background colors of the given FACE.
  840. `M-x make-face-bold'
  841.      Make the font of the given FACE bold.  When called from a program,
  842.      returns `nil' if this is not possible.
  843. `M-x make-face-bold-italic'
  844.      Make the font of the given FACE bold italic.  When called from a
  845.      program, returns `nil' if not possible.
  846. `M-x make-face-italic'
  847.      Make the font of the given FACE italic.  When called from a
  848.      program, returns `nil' if not possible.
  849. `M-x make-face-unbold'
  850.      Make the font of the given FACE non-bold.  When called from a
  851.      program, returns `nil' if not possible.
  852. `M-x make-face-unitalic'
  853.      Make the font of the given FACE non-italic.  When called from a
  854.      program, returns `nil' if not possible.
  855. `M-x set-face-background'
  856.      Change the background color of the given FACE.
  857. `M-x set-face-background-pixmap'
  858.      Change the background pixmap of the given FACE.
  859. `M-x set-face-font'
  860.      Change the font of the given FACE.
  861. `M-x set-face-foreground'
  862.      Change the foreground color of the given FACE.
  863. `M-x set-face-underline-p'
  864.      Change whether the given FACE is underlined.
  865.    You can exchange the foreground and background color of the selected
  866. FACE with the function `invert-face'. If the face does not specify both
  867. foreground and background, then its foreground and background are set
  868. to the background and foreground of the default face.  When calling
  869. this from a program, you can supply the optional argument SCREEN to
  870. specify which screen is affected; otherwise, all screens are affected.
  871.    You can set the background color of the specified FACE with the
  872. function `set-face-background'.  The argument `color' should be a
  873. string, the name of a color.  When called from a program, if the
  874. optional SCREEN argument is provided, the face is changed only in that
  875. screen; otherwise, it is changed in all screens.
  876.    You can set the background pixmap of the specified FACE with the
  877. function `set-face-background-pixmap'.  The pixmap argument NAME should
  878. be a string, the name of a file of pixmap data.  The directories listed
  879. in the `x-bitmap-file-path' variable are searched.  The bitmap may also
  880. be a list of the form `(width height data)' where width and height are
  881. the size in pixels, and data is a string containing the raw bits of the
  882. bitmap.  If the optional SCREEN argument is provided, the face is
  883. changed only in that screen; otherwise, it is changed in all screens.
  884.    The variable `x-bitmap-file-path' takes as a value a list of the
  885. directories in which X bitmap files may be found.  If the value is
  886. `nil', the list is initialized from the `*bitmapFilePath' resource.
  887.    You can set the font of the specified FACE with the function
  888. `set-face-font'.  The FONT argument should be a string, the name of a
  889. font.  When called from a program, if the optional SCREEN argument is
  890. provided, the face is changed only in that screen; otherwise, it is
  891. changed in all screens.
  892.    You can set the foreground color of the specified FACE with the
  893. function `set-face-foreground'.  The argument COLOR should be a string,
  894. the name of a color.  If the optional SCREEN argument is provided, the
  895. face is changed only in that screen; otherwise, it is changed in all
  896. screens.
  897.    You can set underline the specified FACE with the function
  898. `set-face-underline-p'. The argument UNDERLINE-P can be used to make
  899. underlining an attribute of the face or not. If the optional SCREEN
  900. argument is provided, the face is changed only in that screen;
  901. otherwise, it is changed in all screens.
  902.